home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9466 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  60 lines

  1. Path: news.urz.uni-heidelberg.de!usenet
  2. From: Ramon Wartala <r.wartala@dkfz-heidelberg.de>
  3. Newsgroups: comp.lang.c
  4. Subject: CALL_BY_VALUE with ARRAYS ?
  5. Date: Mon, 11 Mar 1996 14:28:56 +0100
  6. Organization: dkfz Heidelberg, Abteilung Medizinische Physik
  7. Message-ID: <31442A98.41C6@dkfz-heidelberg.de>
  8. NNTP-Posting-Host: radxw2.inet.dkfz-heidelberg.de
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; AIX 2)
  13.  
  14. Hello World,
  15.  
  16.  
  17. I've a problem which risks to break my nervs.
  18.  
  19.  
  20. How can I call a function by a pointer, and giving her
  21. a number of paramters which I don't know before executing ?
  22.  
  23. Exp. 
  24.  
  25. Funcion :
  26.  
  27.    int foo(char a, char b , char c) {}
  28.  
  29.  
  30.    void main()
  31.     {
  32.       int (*ptr)()=foo;
  33.       /* .... */
  34.       /* calling my function now ... */
  35.       (ptr)(a_variable);
  36.       /* ... while variable is a just a structure of 3 char. long */
  37. }
  38.  
  39.  
  40. The problem is, that I can define such a structure (e.g. by char
  41. a_variable[3]), but if I try to give it to my function foo, the 
  42. compiler gives naturally only the reference of this 3-byte buffer
  43. (which is totaly normal) to my function foo.
  44.  
  45. So my question could be explained with other words :
  46.  
  47. How can I force the compiler ( gcc for preference) to make a
  48. call_by_value although with arrays ?
  49.  
  50.  
  51. Thanks in advane for your help !
  52.  
  53.  
  54. Jens
  55.  
  56.  
  57. *** Jens Astor                        *****
  58. *** jastor@jupiter.rz.fh-heilbronn.de *****
  59. *** University of Heidelberg, Germany *****
  60.